home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / UsingObjects / ScreenObject.s < prev    next >
Encoding:
Text File  |  1997-05-01  |  3.4 KB  |  117 lines

  1. ;-------T-------T------------------------T---------------------------------;
  2. ;Open a screen using an external OBJect file.
  3. ;--------------------------------------------
  4. ;This demo will open a screen, based on the parameters in an external object
  5. ;file.  This allows a VERY high level of external editing that will alter
  6. ;how this program behaves, without having to reassemble it.
  7. ;
  8. ;This feature is highly important as it allows up to 100% configurability of
  9. ;your game, which previously has only been available to applications using
  10. ;libraries such as MUI.  However, it is even more powerful than this as
  11. ;graphic artists could not only create new datasets for your game, but also
  12. ;alter the dimensions, colours, resolution, attributes (and more) of your
  13. ;BOBs and screens.  Support for code segments is also available, so
  14. ;external functions could be altered and improved by programmers.  This will
  15. ;ensure that your game has a long lasting future as it keeps up with current
  16. ;technology and additions to GMS.
  17. ;
  18. ;I hope you make the most of external objects, its worth it!
  19.  
  20.     INCDIR    "INCLUDES:"
  21.     INCLUDE    "games/games_lib.i"
  22.     INCLUDE    "games/games.i"
  23.  
  24. CALL    MACRO
  25.     jsr    _LVO\1(a6)
  26.     ENDM
  27.  
  28.     SECTION    "ObjectTags",CODE
  29.  
  30. ;===========================================================================;
  31. ;                             INITIALISE DEMO
  32. ;===========================================================================;
  33.  
  34.     STARTGMS
  35.  
  36. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  37.     move.l    GMSBase(pc),a6
  38.     lea    OBJName(pc),a0
  39.     CALL    LoadObjectFile
  40.     move.l    d0,ObjectBase
  41.     beq    .Error_ObjectFile
  42.  
  43.     move.l    ObjectBase(pc),a0    ;a0 = Object Base.
  44.     lea    TXT_ScreenName(pc),a1    ;a1 = The name of the object to get.
  45.     CALL    GetObject    ;>> = Get our GameScreen object.
  46.     move.l    d0,Screen    ;a0 = Screen tags of our object.
  47.     beq.s    .Error_Screen    ;>> = Quit if error.
  48.  
  49.     move.l    ObjectBase(pc),a0    ;a0 = Object Base.
  50.     lea    TXT_PictureName(pc),a1    ;a1 = The name of the object to get.
  51.     CALL    GetObject    ;>> = Get our GameScreen object.
  52.     move.l    d0,Picture    ;>> = Picture tags of our object.
  53.     beq.s    .Error_Screen    ;>> = Quit if error.
  54.  
  55.     move.l    Screen(pc),a0    ;a0 = GameScreen tags
  56.     CALL    AddScreen    ;>> = Initialise the screen.
  57.     tst.l    d0    ;ma = Save pointer to the GameScreen.
  58.     beq.s    .Error_Screen    ;>> = Quit if error.
  59.  
  60.     move.l    Screen(pc),a0
  61.     move.l    Picture(pc),a1
  62.     move.l    GS_MemPtr1(a0),PIC_Data(a1)
  63.     CALL    LoadPic
  64.     tst.l    d0
  65.     beq.s    .Error_Picture
  66.  
  67.     move.l    Screen(pc),a0
  68.     move.l    Picture(pc),a1
  69.     move.l    PIC_Palette(a1),GS_Palette(a0)
  70.     CALL    UpdatePalette
  71.  
  72.     CALL    ShowScreen
  73.  
  74.     bsr.s    Main
  75.  
  76. .ReturnToDOS
  77.     move.l    GMSBase(pc),a6
  78.     move.l    Picture(pc),a1
  79.     CALL    FreePic
  80. .Error_Picture
  81.     move.l    Screen(pc),a0
  82.     CALL    DeleteScreen
  83. .Error_Screen
  84.     move.l    ObjectBase(pc),a0
  85.     CALL    FreeObjectFile
  86. .Error_ObjectFile
  87.     MOVEM.L    (SP)+,A0-A6/D1-D7
  88.     moveq    #ERR_OK,d0
  89.     rts
  90.  
  91. ;===========================================================================;
  92. ;                                MAIN LOOP
  93. ;===========================================================================;
  94.  
  95. Main:    CALL    WaitVBL
  96.     moveq    #JPORT1,d0
  97.     CALL    ReadMouse
  98.     btst    #MB_LMB,d0
  99.     beq.s    Main
  100.     rts
  101.  
  102. ;===========================================================================;
  103. ;                                  DATA
  104. ;===========================================================================;
  105.  
  106. ObjectBase:    dc.l  0
  107. OBJName:    dc.b  "GMS:demos/data/OBJ.Screen",0
  108.         even
  109. Screen:        dc.l  0
  110. Picture:    dc.l  0
  111.  
  112. TXT_ScreenName:    dc.b  "Screen",0
  113.         even
  114. TXT_PictureName    dc.b  "Picture",0
  115.         even
  116.  
  117.